<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>历史处理数据参考</title>
</head>
<body>

<!-- 历史处理数据参考模态框片段 -->
<div th:fragment="statsModal" class="modal fade" id="issueStatsModal" tabindex="-1" role="dialog" aria-labelledby="issueStatsModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="issueStatsModalLabel">
                    <i class="fa fa-bar-chart"></i> 历史处理数据参考
                </h4>
            </div>
            <div class="modal-body">
                <!-- 类别统计卡片 -->
                <div class="panel panel-default" id="categoryStatsCard">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <i class="fa fa-pie-chart"></i> 同类需求处理统计
                        </h4>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="info-box bg-blue">
                                    <span class="info-box-icon"><i class="fa fa-clock-o"></i></span>
                                    <div class="info-box-content">
                                        <span class="info-box-text">平均处理时间</span>
                                        <span class="info-box-number" id="avgProcessingTime">--</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="info-box bg-green">
                                    <span class="info-box-icon"><i class="fa fa-check-circle"></i></span>
                                    <div class="info-box-content">
                                        <span class="info-box-text">一次通过率</span>
                                        <span class="info-box-number" id="successRate">--</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="info-box bg-yellow">
                                    <span class="info-box-icon"><i class="fa fa-redo"></i></span>
                                    <div class="info-box-content">
                                        <span class="info-box-text">返工率</span>
                                        <span class="info-box-number" id="retryRate">--</span>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="info-box bg-purple">
                                    <span class="info-box-icon"><i class="fa fa-database"></i></span>
                                    <div class="info-box-content">
                                        <span class="info-box-text">样本数量</span>
                                        <span class="info-box-number" id="sampleCount">--</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="row" style="margin-top: 15px;">
                            <div class="col-md-12">
                                <div class="alert alert-info">
                                    <i class="fa fa-info-circle"></i> 
                                    基于同类需求的历史数据，系统预测当前需求的处理时间约为 <strong id="estimatedTime">--</strong> 小时。
                                    <button class="btn btn-xs btn-primary" onclick="showRecommendedAssignee()">
                                        <i class="fa fa-user"></i> 查看推荐处理人
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 推荐处理人卡片 -->
                <div class="panel panel-default" id="recommendedAssigneeCard" style="display: none;">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <i class="fa fa-user-plus"></i> 推荐处理人
                        </h4>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-6">
                                <p><strong>推荐处理人:</strong> <span id="assigneeName">--</span></p>
                                <p><strong>平均处理时间:</strong> <span id="assigneeAvgTime">--</span> 小时</p>
                            </div>
                            <div class="col-md-6">
                                <p><strong>成功处理次数:</strong> <span id="assigneeSuccessCount">--</span></p>
                                <p><strong>总处理次数:</strong> <span id="assigneeTotalCount">--</span></p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 历史处理记录表格 -->
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <i class="fa fa-history"></i> 同类需求处理记录
                        </h4>
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th>需求ID</th>
                                        <th>需求标题</th>
                                        <th>处理人</th>
                                        <th>操作类型</th>
                                        <th>处理时长</th>
                                        <th>操作时间</th>
                                    </tr>
                                </thead>
                                <tbody id="similarHistoryList">
                                    <tr>
                                        <td colspan="6" class="text-center">
                                            <i class="fa fa-spinner fa-spin"></i> 正在加载历史记录...
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                
                <!-- 数据分析图表 -->
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4 class="panel-title">
                            <i class="fa fa-line-chart"></i> 处理时间分布
                        </h4>
                    </div>
                    <div class="panel-body">
                        <div id="processingTimeChart" style="height: 300px;"></div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="refreshStatsData()">
                    <i class="fa fa-refresh"></i> 刷新数据
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>